package com.jblv.frame.demo.kafka;


import com.jblv.frame.common.kafka.KafkaConsumerUtils;
import com.jblv.frame.common.kafka.MessageHandler;

/**
 * @author happyonion.yangtao
 * @version 1.0
 * @title ApacheKfaka
 * @projectName jblv-frame
 * @packageName com.jblv.web.kafka
 * @description
 * @date Create at 2020/4/17 13:48
 * @since jdk1.8
 */

public class MsgQueueListener {


    // 监听主题数组
    private final static String[] TOPICS = new String[]{
           "kafka-topic2"
    };

    // 监听主题对应的处理类对象数组
    private final static MessageHandler[] handlers = new MessageHandler[]{
            new SmsNotifyHandler()
    };


    /**
     * 启动kafka监听通知消息处理事件
     */
    public static void start() {
        KafkaConsumerUtils.newInstance().consume(TOPICS, handlers);
    }

    /**
     * 停止监听
     */
    public static void stop() {
        KafkaConsumerUtils.newInstance().close();
    }


}
